package com.ts.api.module.match.plan.model;

import com.ts.api.module.api.entity.ApiUserRequest;
import com.ts.api.module.match.plan.internal.core.PlanMatchChannelType;
import com.ts.api.module.match.plan.internal.distribute.model.PlanDistributeResult;
import com.ts.api.module.match.plan.internal.qualification.model.PlanQualificationResult;
import lombok.Data;

import java.util.List;

/**
 *  计划匹配处理数据实体
 *
 *  @author Pan
 */
@Data
public class PlanMatchProcess {

    /** 本次请求id */
    private String reqId;
    /** 计划匹配 */
    private AbstractPlanMatch abstractPlanMatch;
    /** API传输对象 */
    private ApiUserRequest sourceApiUserRequest;
    /** 计划分发结果 */
    private List<PlanDistributeResult> listMatchResult;
    /** 匹配渠道类型 */
    private PlanMatchChannelType planMatchChannelType;

    public PlanMatchProcess() {
        super();
    }

    /**
     *  构建数据模型
     *
     *  @param  planQualificationResult        计划资质响应
     *  @param  listMatchResult                匹配结果集合
     *  @return PlanMatchProcess
     */
    public static PlanMatchProcess of(PlanQualificationResult planQualificationResult, List<PlanDistributeResult> listMatchResult) {
        AbstractPlanMatch abstractPlanMatch = planQualificationResult.getAbstractPlanMatch();

        PlanMatchProcess planMatchProcess = new PlanMatchProcess();
        planMatchProcess.setAbstractPlanMatch(abstractPlanMatch);
        planMatchProcess.setReqId(planQualificationResult.getReqId());
        planMatchProcess.setSourceApiUserRequest(planQualificationResult.getApiUserRequest());
        planMatchProcess.setPlanMatchChannelType(abstractPlanMatch.getPlanMatchChannelType());
        planMatchProcess.setListMatchResult(listMatchResult);
        return planMatchProcess;
    }
}
